<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../src/pub-sub/index.js"></script>
</head>
<body>
  <script>
    // 订阅一个频道
    const pid1 = PubSub.subscribe('pay', data => {
      console.log('商家接到订单，准备开始制作：', data);
    })

    const pid2 = PubSub.subscribe('pay', data => {
      console.log('商家接到订单，准备取餐：', data);
    })

    PubSub.subscribe('cancel', data => {
      console.log('商家接到了取消的通知：', data);
    })

    // console.log(pid1, pid2);


    // 取消订阅
    // PubSub.unsubscribe('pay')
    PubSub.unsubscribe(pid2)


    // // 发布消息
    PubSub.publish('pay', '香辣鸡腿堡')

  </script>
</body>
</html>